package com.XiaoLongGroup.webtech.mapper;/**
 * @author : SLCcccc
 * @date : 2023/4/11 14:21
 */

import com.XiaoLongGroup.webtech.Cache.CacheRelations;
import com.XiaoLongGroup.webtech.Cache.RelativeCache;
import com.XiaoLongGroup.webtech.entity.User;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 *@ClassName UserMapper
 *@Description TODO
 *@Author SLCcccc
 *@Date 2023/4/11 14:21
 */
@Mapper
@Repository
@CacheNamespace(implementation = RelativeCache.class, eviction = RelativeCache.class, flushInterval = 30 * 60 * 1000)
@CacheRelations(from = ArticleMapper.class)
public interface UserMapper {
    /**
     * ToDo: 查找用户列表
     * @return {@link List <User>}
     * @author Yuhaotian
     * @date. 2022/11/22 11:27
     * @since 1.0.0
     */
    List<User> getAllUserList();

    /**
     * 获取用户列表
     * @param page
     * @param size
     * @return
     */
    List<User> getUserList(@Param("page") int page,@Param("size") int size);

    /**
     * 新增用户
     * @param user
     * @return
     */
    int addUser(User user);

    /**
     * 新增用户
     * @param user
     * @return
     */
    int addUser2(User user);

    /**
     * 根据id获取用户
     * @param id
     * @return
     */
    User getUserByUserId(@Param("userId") String id);

    /**
     * 删除用户
     * @param userId
     * @return
     */
    int deleteUserByUserId(@Param("userId") String userId);

    /**
     * 更新用户
     * @param user
     * @return
     */
    int updateUser(User user);

    /**
     * 获取用户总数
     * @return
     */
    int getCount(String search);

    /**
     * 根据nickname模糊查找
     * @param nickName
     * @param page
     * @param size
     * @return
     */
    List<User> getUserListByNameLike(@Param("nickName") String nickName, @Param("page") int page,@Param("size") int size);

    /**
     * 按照用户名精确查找用户信息
     * @param nickName
     * @return
     */
    User getUserByNickName(@Param("nickName") String nickName);

    /**
     * 根据IdAndPassword获取用户
     * @param id
     * @param password
     * @return
     */
    User getUserByUserIdAndPassword(@Param("id") String id, @Param("password") String password);



}
